# 抖码算法，让算法学习变得简单有趣
# 作者：老汤


def zhuan_sai_zi(flip_direction, sz):
    s1, s2, s3 = sz[0], sz[1], sz[2]
    s4, s5, s6 = sz[3], sz[4], sz[5]
    # 骰子转向各个方向的重新排序
    if flip_direction == "L":
        return s5 + s6 + s3 + s4 + s2 + s1
    elif flip_direction == "R":
        return s6 + s5 + s3 + s4 + s1 + s2
    elif flip_direction == "F":
        return s1 + s2 + s5 + s6 + s4 + s3
    elif flip_direction == "B":
        return s1 + s2 + s6 + s5 + s3 + s4
    elif flip_direction == "A":
        return s4 + s3 + s1 + s2 + s5 + s6
    elif flip_direction == "C":
        return s3 + s4 + s2 + s1 + s5 + s6

    return ""


s = str(input())
# 骰子的初始状态
res = "123456"
for i in range(len(s)):
    res = zhuan_sai_zi(s[i], res)

print(res)